export{}


class Person{
    myName:string;
    constructor(n:string){
        this.myName=n;
    }
    getName():string{
        return this.myName;
    }
}

//类及继承写法   还是用extends

class newPerson extends Person{
    age:number;
    constructor(name:string,age:number){//constructor是用于接受参数
        super(name);//super()简单理解是调用父类的constructor
        this.age=age
    }
    getName():string{//这里子类与父类属性同名，父类就不再执行，只执行子类
        return '我叫'+ this.myName;
    }
}


let myObj:newPerson=new newPerson("123",18);
console.log(myObj.getName());
console.log(myObj.age);
console.log(myObj.myName);


